#define _CRT_SECURE_NO_WARNINGS 1
struct ListNode* newnode = (struct ListNode*)malloc(sizeof(struct ListNode));
if (newnode == NULL)
{
	perror("malloc failed");
	return NULL;
}

newnode->val = i;
newnode->next = NULL;

return newnode;

}
struct ListNode* CreatList(int n)
{
	int i = 1;
	struct ListNode* head = NULL;
	struct ListNode* tail = NULL;

	while (i <= n)
	{

		struct ListNode* newnode = BuyNode(i++);
		if (tail == NULL)
		{
			head = tail = newnode;
		}
		else
		{
			tail->next = newnode;
			tail = tail->next;
		}
	}
	tail->next = head;

	return head;
}